package com.dyz.LeetCodeforSwordFingerOffer;

/**
 * @author: daiyizheng
 * @date: 2021/7/3 12:00
 * @description:
 */
public class MissingNumber53 {
    public static void main(String[] args) {
        int []nums = new int[]{0,1,2,3,4,5,6,7,9};
        int n = new MissingNumber53().missingNumber(nums);
        System.out.println(n);
    }
    public int missingNumber(int[] nums) {
        int i = 0, j = nums.length - 1;
        while(i <= j) {
            int m = (i + j) / 2;
            if(nums[m] == m) {i = m + 1;}
            else {j = m - 1;}
        }
        return i;
    }
}
